<script>
	import store from '@/store/index.js'
	import { common } from '@/api/public.js'
	import { addressList } from '@/api/user.js'
	// import webscoket from '@/utils/web_scket.js'
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef MP-WEIXIN
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect().top
			store.commit('set_menuButtonInfo', menuButtonInfo + 'px')
			// #endif
			// #ifdef H5
			store.commit('set_menuButtonInfo', '20px')
			// #endif

			// 获取缓存是否有店铺信息
			let dp_id = uni.getStorageSync('dl_id')
			let dp_msg = uni.getStorageSync('dl_msg')

			// 获取用户当前位置
			uni.getLocation({
				type: 'gcj02',
				success: (res) => {
					if (res.errMsg == 'getLocation:ok') {
						console.log('woxian')
						store.commit('set_lat', res.latitude)
						store.commit('set_lon', res.longitude)
						uni.setStorageSync('lat', res.latitude)
						uni.setStorageSync('lon', res.longitude)
						// 公共参数
						common().then(res => {
							console.log('wohou')
							if (res.code == 1) {
								//存入vuex
								store.commit('set_common', res.data)
								// 店铺信息存入vuex
								if (!dp_msg) {
									store.commit('set_dl_id', res.data.dl.user_id)
									store.commit('set_dl_msg', res.data.dl)
								}
							}
						})
					}
				},
				fail: (res) => {
					console.log(res)
					// 公共参数
					common().then(res => {
						if (res.code == 1) {
							//存入vuex
							store.commit('set_common', res.data)
							// 店铺信息存入vuex
							if (!dp_msg) {
								store.commit('set_dl_id', res.data.dl.user_id)
								store.commit('set_dl_msg', res.data.dl)
							}
						}
					})
				}
			})
			// 获取用户收货地址
			addressList().then(res => {
				if (res.code == 1) {
					store.commit('set_address_list', res.data)
				}
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";

	/*每个页面公共css */
	.font_family {
		font-family: PingFang SC, PingFang SC;
	}

	// 页面公共背景色
	.content {
		background: #F4F5FA;
		min-height: 100vh;
		box-sizing: border-box;
	}

	.loadmore_box {
		margin-top: 30rpx;
		padding-bottom: 30rpx;
	}

	// 主 交对齐
	.f {
		display: flex;
	}

	.f_z_b {
		display: flex;
		justify-content: space-between;
	}

	.f_z_a {
		display: flex;
		justify-content: space-around;
	}

	.f_j_e {
		display: flex;
		align-items: flex-end;
	}

	.f_d {
		display: flex;
		flex-direction: column;
	}

	.f_zj {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.f_z {
		display: flex;
		justify-content: center;
	}

	.f_j {
		display: flex;
		align-items: center;
	}

	.f_w {
		flex-wrap: wrap;
	}

	// 文本超出长度省略
	.text_ellipsis {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.text_ellipsis2 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		white-space: normal;
	}

	.text_ellipsis3 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
		white-space: normal;
	}

	.p_f_top {
		position: fixed;
		top: 0;
		left: 0;
	}

	.p_f_bottom {
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.safe_bottom {
		// height: calc(60px + env(safe-area-inset-bottom) /2);
		padding-bottom: calc(30rpx + env(safe-area-inset-bottom) /2) !important;
	}

	.empty_top {
		margin-top: 50rpx;
	}

	.empty_p_bot {
		padding-bottom: 30rpx;
	}

	.m_t_10 {
		margin-top: 10rpx;
	}

	.m_t_15 {
		margin-top: 15rpx;
	}

	.m_t_20 {
		margin-top: 20rpx;
	}

	.js_movable {
		width: 100vw;
		height: 95vh;
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		z-index: 9999999;
		pointer-events: none;

		.js_view {
			// width: 100vw;
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			background-color: #ED4133;
			pointer-events: all;

			.kf_btn {
				background: none;
				line-height: normal;
				font-size: 26rpx;
				color: #FFFFFF;

				image {
					width: 42rpx;
					height: 42rpx;
					margin-bottom: 6rpx;
				}

			}

			.kf_btn::after {
				border: none;
			}
		}
	}

	.boxsizing {
		box-sizing: border-box;

	}

	.w100 {
		width: 100%;
	}

	.w100h100 {
		width: 100%;
		height: 100%;
	}

	.flex {
		display: flex;
	}

	.ds {
		display: flex;
	}

	.jc {
		justify-content: center;
	}

	.jsa {
		justify-content: space-around;
	}

	.jsb {
		justify-content: space-between;
	}

	.ac {
		align-items: center;
	}

	.ae {
		align-items: flex-end;
	}

	.je {
		justify-content: flex-end;
	}

	.asb {
		align-content: space-between;
	}

	.flexwrap {
		flex-wrap: wrap;
	}

	.me-text-beyond {
		/*文本内容超宽度省略号显示 单行*/
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.m030 {
		margin: 0 30rpx;
	}

	.bfff {
		background-color: #fff;
	}

	.plank {
		width: 100%;
		height: 1rpx;
	}

	.p030 {
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.Bench {
		width: 100%;
		height: 100rpx;
	}

	.asa {
		align-content: space-around;
	}
</style>